Back to course home
0% completed
Vote For New Content
Google Medium
Gray Code (medium)
Solution: Gray Code
2 Keys Keyboard (medium)
Solution: 2 Keys Keyboard
Arithmetic Slices (medium)
Solution: Arithmetic Slices
Unique Length-3 Palindromic Subsequences (medium)
Solution: Unique Length-3 Palindromic Subsequences
Minimum Difference Between Largest and Smallest Value in Three Moves (medium)
Solution: Minimum Difference Between Largest and Smallest Value in Three Moves
Letter Combinations of a Phone Number (medium)
Solution: Letter Combinations of a Phone Number
01 Matrix (medium)
Solution: 01 Matrix
Maximum Points You Can Obtain from Cards (medium)
Solution: Maximum Points You Can Obtain from Cards
Strobogrammatic Number II (medium)
Solution: Strobogrammatic Number II
Maximum Length of Semi-Decreasing Subarrays (medium)
Solution: Maximum Length of Semi-Decreasing Subarrays
Minimum Area Rectangle (medium)
Solution: Minimum Area Rectangle
Count Unreachable Pairs of Nodes in an Undirected Graph (medium)
Solution: Count Unreachable Pairs of Nodes in an Undirected Graph
Single Number II (medium)
Solution: Single Number II
4Sum II (medium)
Solution: 4Sum II
Furthest Building You Can Reach (medium)
Solution: Furthest Building You Can Reach
Minimizing Array After Replacing Pairs With Their Product (medium)
Solution: Minimizing Array After Replacing Pairs With Their Product
Fair Distribution of Cookies (medium)
Solution: Fair Distribution of Cookies
Find Leaves of Binary Tree (medium)
Solution: Find Leaves of Binary Tree
Rotate Image (medium)
Solution: Rotate Image
Combination Sum (medium)
Solution: Combination Sum
Implement Trie (Prefix Tree) (medium)
Solution: Implement Trie (Prefix Tree)
Number of Islands (medium)
Solution: Number of Islands
Edit Distance (medium)
Solution: Edit Distance
Container With Most Water (Medium)
Solution: Container With Most Water
Meeting Rooms II (medium)
Solution: Meeting Rooms II
Google Hard
Shortest Subarray with Sum at Least K (hard)
Solution: Shortest Subarray with Sum at Least K
Reverse Pairs (hard)
Solution: Reverse Pairs
Nth Magical Number (hard)
Solution: Nth Magical Number
Candy (hard)
Solution: Candy
Arithmetic Slices II - Subsequence (hard)
Solution: Arithmetic Slices II - Subsequence
Burst Balloons (hard)
Solution: Burst Balloons
Sum of Distances in Tree (hard)
Solution: Sum of Distances in Tree
Maximum Score of a Good Subarray (hard)
Solution: Maximum Score of a Good Subarray
Trapping Rain Water (hard)
Solution: Trapping Rain Water
First Missing Positive (hard)
Solution: First Missing Positive
Find the Difference of Two Arrays (easy)
Problem Statement
Given two integer arrays nums1 and nums2, return an answer list of size where:
answer[0]is alistof allunique integersinnums1that are not present innums2.answer[1]is alistof allunique integersinnums2that are not present innums1.
You may return the integers in the list in any order.
Examples
-
Example 1:
- Input:
nums1 = [2, 3, 4], nums2 = [1, 2] - Expected Output:
[[3, 4], [1]] - Justification: The number
2is common in both arrays.3and4are unique tonums1, and1is unique tonums2.
- Input:
-
Example 2:
- Input:
nums1 = [0, 2, 4, 6], nums2 = [1, 3, 5, 7] - Expected Output:
[[0, 2, 4, 6], [1, 3, 5, 7]] - Justification: All numbers in both arrays are unique to their respective array as there's no overlap between
nums1andnums2.
- Input:
-
Example 3:
- Input:
nums1 = [10, 20, 20, 30, 90], nums2 = [20, 30, 40, 50] - Expected Output:
[[10, 90], [40, 50]] - Justification: The numbers
20and30are present in both arrays, so they are excluded.10and90are unique tonums1, and40,50are unique tonums2. Duplicates in the input are ignored.
- Input:
Try it yourself
Try solving this question here:
Java
Saved to Cloud
. . . .
Solution: Binary Tree Paths
Solution: Find the Difference of Two Arrays
Mark as Completed
On this page
Problem Statement
Examples
Try it yourself